home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mission 3
/
Mission 3.zip
/
Mission 3.iso
/
vollvers
/
adamaslg
/
ovl.src
/
x32play.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-18
|
3KB
|
140 lines
#include "extern.h"
#include <stddef.h>
#include <time.h>
#include <vdi.h>
#include <stdio.h>
int sys;
extern int tx_width, tx_height;
/*
Initialize X32-Player plug-in.
This function will be only called once, after loading the plug-in.
*/
int cdecl init_ovl(int *sysinfo, BASPAG *baspag)
{
_BasPag = baspag;
sys = sysinfo[0]; /* 0 = Single; 1 = Mint; 2 = MagX, 3 = MultiTOS */
open_panelvwk();
Mshrink(0, baspag,
TEXTsize(baspag) + DATAsize(baspag) + BSSsize(baspag) + sizeof(BASPAG));
return TRUE;
}
/*
Release X32-Sound object.
This function will be called on destroying an
object inside the web-page.
*/
int cdecl release_ovl(OBJ_INFO *oinf)
{
if (((X32_INFO *)oinf->user)->playing) /* Is it playing */
stop_sound(oinf);
if (oinf->user)
{
X32_INFO *x32info;
x32info = oinf->user;
Mfree(x32info->name); /* Free name memory */
Mfree(x32info->data); /* Free data memory */
Mfree(x32info); /* Free managment structure */
oinf->user = NULL;
}
return TRUE;
}
/*
Remove X32Player plug-in.
This function will be called only once before
unloading the plug-in.
*/
int cdecl exit_ovl(void)
{
close_panelvwk();
Mfree(_BasPag->p_env); /* Free allocated environment */
return !Mfree(_BasPag); /* Free plug-in */
}
/*
Play sound
*/
int cdecl execute_ovl(char *src, OBJ_INFO *oinf)
{
char *s;
int w;
long fh, length;
s = strrchr(src, '\\');
if (!s) s = src; else s++;
w = (int)strlen(s) * tx_width + 4; /* Calculate text width */
if (oinf->obj_w == -1) /* No size set ? */
oinf->obj_w = w;
if (oinf->obj_h == -1)
oinf->obj_h = 16;
w += oinf->obj_h * 2;
if (w > oinf->obj_w && oinf->obj_w) /* If it is to small and a */
oinf->obj_w = w; /* width is given resize to minimum */
/* width */
if (tx_height > oinf->obj_h && oinf->obj_h) /* Same for the height */
oinf->obj_h = tx_height;
if (!oinf->user) /* No user area ? */
{
X32_INFO *x32info;
x32info = (X32_INFO *)Malloc(sizeof(X32_INFO));
oinf->user = x32info; /* Allocate user structure */
x32info->name = (char *)Malloc(strlen(s) + 1);
strcpy(x32info->name, s); /* Copy filename */
fh = Fopen(src, FO_READ);
if (fh > 0) /* Is file opened? */
{
length = Fseek(0, (int)fh, 2);
Fseek(0, (int)fh, 0);
x32info->data = (char *)Mxalloc(length, 0);
Fread((int)fh, length, x32info->data); /* Load XB32 data */
Fclose((int)fh);
}
else
x32info->data = NULL;
x32info->button_pressed = -1;
}
/* If it should start automatically and it is not running now,
then start it. */
if (oinf->started >= 0 && !((X32_INFO *)oinf->user)->playing)
start_sound(oinf);
return 1;
}
/*
Object timer function, takes care about the looping
*/
long cdecl timer_ovl(OBJ_INFO *oinf)
{
if (((X32_INFO *)oinf->user)->playing && oinf->loop)
{
if (!DosoundX32((void *)-1L))
start_sound(oinf);
}
return CLK_TCK;
}